package com.dayangxiaoen.pms.controller;


import com.dayangxiaoen.pms.service.ExchangeAmountService;
import com.dayangxiaoen.pms.service.ExchangeWayService;
import com.dayangxiaoen.pms.service.SalesVolumeService;
import com.dayangxiaoen.pms.vo.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author dayangxiaoen
 */
@RestController
@RequestMapping("chart")
@Slf4j
public class ChartController {

    @Autowired
    private ExchangeAmountService exchangeAmountService;

    @Autowired
    private SalesVolumeService salesVolumeService;

    @Autowired
    private ExchangeWayService exchangeWayService;

    @GetMapping("exchangeAmount/{days}")
    public Result getExchangeAmount(@PathVariable int days){
        return exchangeAmountService.findExchangeAmountByDays(days);
    }

    @GetMapping("salesVolume/{days}")
    public Result getSalesVolume(@PathVariable int days){
        return salesVolumeService.findSalesVolumeTop20ByDays(days);
    }

    @GetMapping("exchageWay/{days}")
    public Result getExchageWay(@PathVariable int days){
        return exchangeWayService.findExchangeByDays(days);
    }

}
